#include<iostream>
#include<math.h>
#define MAX 100
#define INF (int)(pow(2,31)-1)
using namespace std;

int s;
int n;
int coins[MAX];
int sol[MAX];

int solve() {
   for(int i=0; i<=s; i++)
      sol[i] = INF;
   sol[0] = 0;
   for(int i=1; i<=s; i++) {
      for(int j=0; j<n; j++) {
         if(coins[j]<=i && sol[i-coins[j]]+1 < sol[i]) {
            sol[i] = sol[i-coins[j]]+1;
         }
      }
   }   
   for(int i=0; i<=s; i++)
      cout << sol[i] << " ";
   cout << endl;
   return sol[s];
}

void read() {
   cin >> s >> n;
   for(int i=0; i<n; i++)
      cin >> coins[i];
   cout << solve();
}

int main() {
   read();
   return 0;
}
